package level.editor.view.toolbar;

import java.awt.Dimension;
import java.awt.FlowLayout;

import javax.swing.AbstractAction;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.border.BevelBorder;

import level.editor.view.Window;
import level.editor.view.action.DesktopAction;
import level.editor.view.action.edit.EditAction;
import level.editor.view.action.file.FileAction;
import level.editor.view.desktop.Desktop;

public class ToolBar extends JPanel
{

	public ToolBar(Window window)
	{
		super(new FlowLayout(FlowLayout.LEADING, 0, 0));
		init(window.getDesktop());
	}

	private void init(Desktop desktop)
	{
		setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));
		for (AbstractAction action : desktop.getActions())
		{
			if (action instanceof FileAction || action instanceof EditAction || action instanceof DesktopAction)
			{
				JButton button = new JButton(action);
				button.setText(null);
				button.setMinimumSize(new Dimension(25, 25));
				button.setMaximumSize(new Dimension(25, 25));
				button.setPreferredSize(new Dimension(25, 25));
				button.setFocusPainted(false);
				button.setFocusable(false);
				add(button);
			}
		}
	}
}
